{include file="public/header"}


<div class="page-container">

    <div class="mt-20">
        <div class="title-border">
            <div class="flex1">序号</div>
            <div class="flex1">编码</div>
            <div class="flex3">存货名称</div>
            <div class="flex1">型号</div>
            <div class="flex2">计价方式</div>
            <div class="flex1">所属类别</div>
            <div class="flex1">品牌</div>
            <div class="flex1">单位</div>
            <div class="flex1">规格</div>
            <div class="flex1">产品描述</div>
            <div class="flex1">参考成本</div>
            <div class="flex1">最新成本</div>
            <div class="flex2">建档日期</div>
            <div class="flex2">操作</div>
        </div>
        {volist name='data' id='vo'}
        <div class="content-border">
            <div class="flex1">{$vo.id}</div>
            <div class="flex1">{$vo.code}</div>
            <div class="flex3">{$vo.stock_name}</div>
            <div class="flex1">{$vo.stock_model}</div>
            <div class="flex2">{$vo.valuation_method}</div>
            <div class="flex1">{$vo.class_table}</div>
            <div class="flex1">{$vo.brand}</div>
            <div class="flex1">{$vo.company}</div>
            <div class="flex1">{$vo.specifications}</div>
            <div class="flex1">{$vo.describe}</div>
            <div class="flex1">{$vo.reference_cost}</div>
            <div class="flex1">{$vo.latest_cost}</div>
            <div class="flex2">{$vo.created_date}</div>
            <div class="flex2">
                <a class="ch-button ch-blue ed" data-id="{$vo.id}" href="javascript:;" title="编辑">编辑</a>
                <a class="ch-button ch-red del" data-id="{$vo.id}" href="javascript:;" title="删除">删除</a>
            </div>
        </div>
        {/volist}
        <div class="pages" style="float: right">{$data->render()}</div>

    </div>
</div>

{include file="public/footer"}
<script type="text/javascript">
    var winWidth = $(window).width();
    var areaWidth = "";
    var areaHeight = "";

    /**
     * 删除
     */
    $('.del').click(function () {
        var id=$(this).attr('data-id');
        var obj={};
        obj.id=id;
        var src="{:Url('index/Stock/del')}";
        layer.confirm('确认要删除吗？', function (index) {
            $.ajax({
                type: 'POST',
                url: src,
                dataType: 'json',
                data: obj,
                success: function (data) {
                    var res=JSON.parse(data);
                    if(res.code==200){
                        layer.msg(res.msg, {icon: 1, time: 2000}, function () {
                            setTimeout("window.location.reload()", 1);
                        });
                    }else{
                        layer.msg(res.msg,{icon: 5,time:1000});
                    }

                },
                error: function (data) {
                    console.log(data.msg);
                },
            });
        });
    });

    $('.ed').click(function () {
        if( winWidth > 768 ){
            areaWidth = "900px"
            areaHeight = "700px"
        } else {
            areaWidth = '90%'
            areaHeight = '300px'
        }
        var id=$(this).attr('data-id');
        var src="{:Url('index/Stock/edit')}";
        layer.open({
            type: 2,
            area: [areaWidth, areaHeight],
            fix: false,
            maxmin: true,
            shade:0.4,
            title: '编辑渠道',
            content: src+'?id='+id
        });
    });

</script>
</body>
</html>